Skip to content

refactor: DatasetInterp delegates to aa.interp_2d; expose xp - #398

Merged
Jammy2211 merged 2 commits into
mainfrom
feature/jax-interp-2d
May 14, 2026
Merged

Jammy2211 merged 2 commits into
mainfrom
feature/jax-interp-2d

Conversation

@Jammy2211

@Jammy2211 Jammy2211 commented May 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Refactor DatasetInterp in autogalaxy/ellipse/dataset_interp.py to delegate 2D interpolation to the new aa.interp_2d helper (shipped in PyAutoArray PR PyAutoLabs/PyAutoArray#308) and to expose an xp parameter for the JAX path. Step 4 of the ellipse_fitting_jax feature — DatasetInterp was the first hard JAX blocker for AnalysisEllipse.log_likelihood_function. NumPy-path behaviour is byte-stable: the prompt-3 reference arrays pin _points_from_major_axis to rtol=1e-12 and pass unchanged; the prompt-2 workspace_test reference numbers match to all 8 printed decimal places.

API Changes

DatasetInterp.{mask,data,noise_map}_interp changed from @cached_property returning scipy.interpolate.RegularGridInterpolator instances to methods (points, xp=np) that return the interpolated (N,) array directly. The original "use the interpolator like a callable" pattern (interp_obj(points)) is preserved — ds.mask_interp(points) still works. The "store the interpolator and re-use" pattern (interp = ds.mask_interp; interp(pts_a); interp(pts_b)) breaks. No known external users follow that pattern. The sentinel check self.interp.mask_interp is not None in fit_ellipse.py:81 is preserved (still always True; a bound method is non-None). See full details below.

Test Plan

  • python -m pytest test_autogalaxy/ellipse/ -v — 30/30 pass, including prompt-3's rtol=1e-12 _points_from_major_axis pins
  • python -m pytest test_autogalaxy/ -x — 858/858 pass
  • python scripts/jax_likelihood_functions/ellipse/{fit,multipoles}.py from autogalaxy_workspace_test/ — all 8 reference numbers match prompt-2 baseline byte-for-byte

Upstream PR

PyAutoLabs/PyAutoArray#308

Full API Changes (for automation & release notes)

Removed

None — the property names are kept; their kind (property → method) changes.

Changed Behaviour

  • autogalaxy.ellipse.DatasetInterp.mask_interp — was @cached_property returning scipy.interpolate.RegularGridInterpolator; now method (points, xp=np) returning np.ndarray or jax.Array directly.
  • autogalaxy.ellipse.DatasetInterp.data_interp — same.
  • autogalaxy.ellipse.DatasetInterp.noise_map_interp — same.

Migration

  • ds.mask_interp(points) — no change.
  • interp = ds.mask_interp; interp(points) — replace with ds.mask_interp(points) (call inline, don't store the bound method as a substitute for an interpolator instance).
  • New JAX path: ds.mask_interp(points, xp=jnp) returns a jax.Array. Not exercised in this PR — wired into the analysis class by prompt 7.

Generated with Claude Code

Converts DatasetInterp.{mask,data,noise_map}_interp from cached properties
returning scipy RegularGridInterpolator instances to methods (points, xp=np)
that call the new aa.numerics.interp_2d helper. Preserves the callable
syntax used by FitEllipse (ds.x(points)) so all six call sites work
unchanged. NumPy-path semantics byte-stable: prompt-3 rtol=1e-12 reference
arrays and prompt-2 workspace_test reference numbers both pass.

Step 4 of the ellipse_fitting_jax feature. Issue PyAutoArray#306.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Follow-up to the PyAutoArray move from autoarray.numerics into
autoarray.operators. No behaviour change.

Issue PyAutoArray#306.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 changed the title refactor: DatasetInterp delegates to aa.numerics.interp_2d; expose xp refactor: DatasetInterp delegates to aa.interp_2d; expose xp May 14, 2026
@Jammy2211
Jammy2211 merged commit fb2f394 into main May 14, 2026
3 of 5 checks passed
@Jammy2211
Jammy2211 deleted the feature/jax-interp-2d branch May 14, 2026 11:25
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant